home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / tsbat146.zip / TOUCH.BAT < prev    next >
DOS Batch File  |  1992-10-25  |  2KB  |  56 lines

  1. @echo off
  2. echo off
  3. echo ┌─────────────────────────────────────────────┐
  4. echo │ Touch a file's datetime stamp               │
  5. echo │ by Prof. Timo Salmi, ts@uwasa.fi, 25-Oct-92 │
  6. echo └─────────────────────────────────────────────┘
  7. echo.
  8.  
  9. if "%1"=="" goto _help
  10. if not exist %1 goto _notfound
  11.  
  12. rem Chech that a path has not been included in the filename
  13. echo @echo off> tmp$$$.bat
  14. echo set rest_=%%1>> tmp$$$.bat
  15. echo :_next>> tmp$$$.bat
  16. echo set prev_=%%rest_%%>> tmp$$$.bat
  17. echo for %%%%g in (/%%rest_%%) do set rest_=%%%%g>> tmp$$$.bat
  18. echo if ":%%rest_%%"=="%%prev_%%" goto _found>> tmp$$$.bat
  19. echo if "\%%rest_%%"=="%%prev_%%" goto _found>> tmp$$$.bat
  20. echo if not "%%rest_%%"=="%%prev_%%" goto _next>> tmp$$$.bat
  21. echo goto _nopath>> tmp$$$.bat
  22. echo :_found>> tmp$$$.bat
  23. echo set haspath_=yes>> tmp$$$.bat
  24. echo goto _out>> tmp$$$.bat
  25. echo :_nopath>> tmp$$$.bat
  26. echo set haspath_=no>> tmp$$$.bat
  27. echo :_out>> tmp$$$.bat
  28. echo set rest_=>> tmp$$$.bat
  29. echo set prev_=>> tmp$$$.bat
  30. for %%f in (%1) do call tmp$$$ %%f
  31. if exist tmp$$$.bat del tmp$$$.bat
  32. if not "%haspath_%"=="yes" goto _touch
  33.  
  34. rem Illegal file name with a path
  35. echo The filename %1 must not include a path
  36. goto _out
  37.  
  38. rem Display the directory and touch the file
  39. :_touch
  40. dir %1
  41. for %%f in (%1) do copy /b /v %%f +,,> nul
  42. dir %1
  43. goto _out
  44.  
  45. :_notfound
  46. echo File %1 not found
  47. goto _out
  48.  
  49. :_help
  50. echo Usage: TOUCH [FileName]
  51. echo No paths, just the filename
  52. echo.
  53.  
  54. :_out
  55. set haspath_=
  56.